﻿using SLNGP.Core.Individuals;

namespace SLNGP.Core.Fitness
{
    public interface IFitnessFunction
    {
        /// <summary>
        /// Sets a fitness value on all members of the generation.
        /// </summary>
        /// <param name="generationToEvaluate"></param>
        void Evaluate(IGeneration generationToEvaluate);

        /// <summary>
        /// Gets or sets the meaning of the fitness determined by a fitness function.
        /// </summary>
        FitnessFunctionOrder FitnessFunctionOrder { get; set; }

        /// <summary>
        /// Gets the effective value of fitness used in Selection. 
        /// The Actual value of fitness is the one returned from the fitness function.
        /// The effective value of fitness is the computed value based on scaling/ordering/sizing. 
        /// </summary>
        /// <param name="ActualFitness">The Individual's fitness as returned from the fitness function.</param>
        /// <returns>A scaled/ordered/sized version of that fitness.</returns>
        /// <param name="generation">The generation containing the individual.</param>
        int GetEffectiveFitness(int ActualFitness, IGeneration generation);

        /// <summary>
        /// Initializes a generation with the information required for effective fitness calculation.
        /// </summary>
        /// <param name="lastGeneration">The generation to be initialized.</param>
        void InitializeForEffectiveFitness(IGeneration generation);

        /// <summary>
        /// Returns (fitness1 > fitness2).
        /// </summary>
        /// <param name="fitness1">First fitness value.</param>
        /// <param name="fitness2">Second fitness value.</param>
        /// <returns>(fitness1 > fitness2)</returns>
        bool IsBigger(object fitness1, object fitness2);
    }
}